home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / etip.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-06-22  |  8.6 KB  |  365 lines

  1. // * This makes emacs happy -*-Mode: C++;-*-
  2. /****************************************************************************
  3.  * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc.              *
  4.  *                                                                          *
  5.  * Permission is hereby granted, free of charge, to any person obtaining a  *
  6.  * copy of this software and associated documentation files (the            *
  7.  * "Software"), to deal in the Software without restriction, including      *
  8.  * without limitation the rights to use, copy, modify, merge, publish,      *
  9.  * distribute, distribute with modifications, sublicense, and/or sell       *
  10.  * copies of the Software, and to permit persons to whom the Software is    *
  11.  * furnished to do so, subject to the following conditions:                 *
  12.  *                                                                          *
  13.  * The above copyright notice and this permission notice shall be included  *
  14.  * in all copies or substantial portions of the Software.                   *
  15.  *                                                                          *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
  17.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
  18.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
  19.  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
  20.  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
  21.  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
  22.  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
  23.  *                                                                          *
  24.  * Except as contained in this notice, the name(s) of the above copyright   *
  25.  * holders shall not be used in advertising or otherwise to promote the     *
  26.  * sale, use or other dealings in this Software without prior written       *
  27.  * authorization.                                                           *
  28.  ****************************************************************************/
  29.  
  30. /****************************************************************************
  31.  *   Author: Juergen Pfeifer, 1997                                          *
  32.  ****************************************************************************/
  33.  
  34. // $Id: etip.h.in,v 1.32 2005/08/06 19:55:57 tom Exp $
  35.  
  36. #ifndef NCURSES_ETIP_H_incl
  37. #define NCURSES_ETIP_H_incl 1
  38.  
  39. // These are substituted at configure/build time
  40. #ifndef HAVE_BUILTIN_H
  41. #define HAVE_BUILTIN_H 0
  42. #endif
  43.  
  44. #ifndef HAVE_GXX_BUILTIN_H
  45. #define HAVE_GXX_BUILTIN_H 0
  46. #endif
  47.  
  48. #ifndef HAVE_GPP_BUILTIN_H
  49. #define HAVE_GPP_BUILTIN_H 0
  50. #endif
  51.  
  52. #ifndef HAVE_STRSTREAM_H
  53. #define HAVE_STRSTREAM_H 0
  54. #endif
  55.  
  56. #ifndef HAVE_TYPEINFO
  57. #define HAVE_TYPEINFO 1
  58. #endif
  59.  
  60. #ifndef HAVE_VALUES_H
  61. #define HAVE_VALUES_H 0
  62. #endif
  63.  
  64. #ifndef ETIP_NEEDS_MATH_H
  65. #define ETIP_NEEDS_MATH_H 1
  66. #endif
  67.  
  68. #ifndef ETIP_NEEDS_MATH_EXCEPTION
  69. #define ETIP_NEEDS_MATH_EXCEPTION 0
  70. #endif
  71.  
  72. #ifndef CPP_HAS_PARAM_INIT
  73. #define CPP_HAS_PARAM_INIT 0
  74. #endif
  75.  
  76. #ifndef CPP_HAS_STATIC_CAST
  77. #define CPP_HAS_STATIC_CAST 1
  78. #endif
  79.  
  80. #ifndef USE_STRSTREAM_VSCAN
  81. #define USE_STRSTREAM_VSCAN 0
  82. #endif
  83.  
  84. #ifndef USE_STRSTREAM_VSCAN_CAST
  85. #define USE_STRSTREAM_VSCAN 0
  86. #endif
  87.  
  88. #ifdef __GNUG__
  89. #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
  90. #    if HAVE_TYPEINFO
  91. #      include <typeinfo>
  92. #    endif
  93. #  endif
  94. #endif
  95.  
  96. #if defined(__GNUG__)
  97. #  if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
  98. #    if ETIP_NEEDS_MATH_H
  99. #      if ETIP_NEEDS_MATH_EXCEPTION
  100. #        undef exception
  101. #        define exception math_exception
  102. #      endif
  103. #      include <math.h>
  104. #    endif
  105. #    undef exception
  106. #    define exception builtin_exception
  107. #    if HAVE_GPP_BUILTIN_H
  108. #     include <gpp/builtin.h>
  109. #    elif HAVE_GXX_BUILTIN_H
  110. #     include <g++/builtin.h>
  111. #    else
  112. #     include <builtin.h>
  113. #    endif
  114. #    undef exception
  115. #  endif
  116. #elif defined (__SUNPRO_CC)
  117. #  include <generic.h>
  118. #endif
  119.  
  120. #include <ncurses_dll.h>
  121.  
  122. extern "C" {
  123. #if HAVE_VALUES_H
  124. #  include <values.h>
  125. #endif
  126.  
  127. #include <assert.h>
  128. #include <eti.h>
  129. #include <errno.h>
  130. }
  131.  
  132. // Language features
  133. #if CPP_HAS_PARAM_INIT
  134. #define NCURSES_PARAM_INIT(value) = value
  135. #else
  136. #define NCURSES_PARAM_INIT(value) /*nothing*/
  137. #endif
  138.  
  139. #if CPP_HAS_STATIC_CAST
  140. #define STATIC_CAST(s) static_cast<s>
  141. #else
  142. #define STATIC_CAST(s) (s)
  143. #endif
  144.  
  145. // Forward Declarations
  146. class NCURSES_IMPEXP NCursesPanel;
  147. class NCURSES_IMPEXP NCursesMenu;
  148. class NCURSES_IMPEXP NCursesForm;
  149.  
  150. class NCURSES_IMPEXP NCursesException
  151. {
  152. public:
  153.   const char *message;
  154.   int errorno;
  155.  
  156.   NCursesException (const char* msg, int err)
  157.     : message(msg), errorno (err)
  158.     {};
  159.  
  160.   NCursesException (const char* msg)
  161.     : message(msg), errorno (E_SYSTEM_ERROR)
  162.     {};
  163.  
  164.   NCursesException& operator=(const NCursesException& rhs)
  165.   {
  166.     errorno = rhs.errorno;
  167.     return *this;
  168.   }
  169.  
  170.   NCursesException(const NCursesException& rhs)
  171.     : message(rhs.message), errorno(rhs.errorno)
  172.   {
  173.   }
  174.  
  175.   virtual const char *classname() const {
  176.     return "NCursesWindow";
  177.   }
  178.  
  179.   virtual ~NCursesException()
  180.   {
  181.   }
  182. };
  183.  
  184. class NCURSES_IMPEXP NCursesPanelException : public NCursesException
  185. {
  186. public:
  187.   const NCursesPanel* p;
  188.  
  189.   NCursesPanelException (const char *msg, int err) :
  190.     NCursesException (msg, err),
  191.     p (NULL)
  192.     {};
  193.  
  194.   NCursesPanelException (const NCursesPanel* panel,
  195.              const char *msg,
  196.              int err) :
  197.     NCursesException (msg, err),
  198.     p (panel)
  199.     {};
  200.  
  201.   NCursesPanelException (int err) :
  202.     NCursesException ("panel library error", err),
  203.     p (NULL)
  204.     {};
  205.  
  206.   NCursesPanelException (const NCursesPanel* panel,
  207.              int err) :
  208.     NCursesException ("panel library error", err),
  209.     p (panel)
  210.     {};
  211.  
  212.   NCursesPanelException& operator=(const NCursesPanelException& rhs)
  213.   {
  214.     if (this != &rhs) {
  215.       NCursesException::operator=(rhs);
  216.       p = rhs.p;
  217.     }
  218.     return *this;
  219.   }
  220.  
  221.   NCursesPanelException(const NCursesPanelException& rhs)
  222.     : NCursesException(rhs), p(rhs.p)
  223.   {
  224.   }
  225.  
  226.   virtual const char *classname() const {
  227.     return "NCursesPanel";
  228.   }
  229.  
  230.   virtual ~NCursesPanelException()
  231.   {
  232.   }
  233. };
  234.  
  235. class NCURSES_IMPEXP NCursesMenuException : public NCursesException
  236. {
  237. public:
  238.   const NCursesMenu* m;
  239.  
  240.   NCursesMenuException (const char *msg, int err) :
  241.     NCursesException (msg, err),
  242.     m (NULL)
  243.     {};
  244.  
  245.   NCursesMenuException (const NCursesMenu* menu,
  246.             const char *msg,
  247.             int err) :
  248.     NCursesException (msg, err),
  249.     m (menu)
  250.     {};
  251.  
  252.   NCursesMenuException (int err) :
  253.     NCursesException ("menu library error", err),
  254.     m (NULL)
  255.     {};
  256.  
  257.   NCursesMenuException (const NCursesMenu* menu,
  258.             int err) :
  259.     NCursesException ("menu library error", err),
  260.     m (menu)
  261.     {};
  262.  
  263.   NCursesMenuException& operator=(const NCursesMenuException& rhs)
  264.   {
  265.     if (this != &rhs) {
  266.       NCursesException::operator=(rhs);
  267.       m = rhs.m;
  268.     }
  269.     return *this;
  270.   }
  271.  
  272.   NCursesMenuException(const NCursesMenuException& rhs)
  273.     : NCursesException(rhs), m(rhs.m)
  274.   {
  275.   }
  276.  
  277.   virtual const char *classname() const {
  278.     return "NCursesMenu";
  279.   }
  280.  
  281.   virtual ~NCursesMenuException()
  282.   {
  283.   }
  284. };
  285.  
  286. class NCURSES_IMPEXP NCursesFormException : public NCursesException
  287. {
  288. public:
  289.   const NCursesForm* f;
  290.  
  291.   NCursesFormException (const char *msg, int err) :
  292.     NCursesException (msg, err),
  293.     f (NULL)
  294.     {};
  295.  
  296.   NCursesFormException (const NCursesForm* form,
  297.             const char *msg,
  298.             int err) :
  299.     NCursesException (msg, err),
  300.     f (form)
  301.     {};
  302.  
  303.   NCursesFormException (int err) :
  304.     NCursesException ("form library error", err),
  305.     f (NULL)
  306.     {};
  307.  
  308.   NCursesFormException (const NCursesForm* form,
  309.             int err) :
  310.     NCursesException ("form library error", err),
  311.     f (form)
  312.     {};
  313.  
  314.   NCursesFormException& operator=(const NCursesFormException& rhs)
  315.   {
  316.     if (this != &rhs) {
  317.       NCursesException::operator=(rhs);
  318.       f = rhs.f;
  319.     }
  320.     return *this;
  321.   }
  322.  
  323.   NCursesFormException(const NCursesFormException& rhs)
  324.     : NCursesException(rhs), f(rhs.f)
  325.   {
  326.   }
  327.  
  328.   virtual const char *classname() const {
  329.     return "NCursesForm";
  330.   }
  331.  
  332.   virtual ~NCursesFormException()
  333.   {
  334.   }
  335. };
  336.  
  337. #if !((defined(__GNUG__) && defined(__EXCEPTIONS)) || defined(__SUNPRO_CC))
  338. #  include <iostream.h>
  339.    extern "C" void exit(int);
  340. #endif
  341.  
  342. inline void THROW(const NCursesException *e) {
  343. #if defined(__GNUG__) && defined(__EXCEPTIONS)
  344. #  if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
  345.       (*lib_error_handler)(e?e->classname():"",e?e->message:"");
  346. #else
  347.       throw *e;
  348. #endif
  349. #elif defined(__SUNPRO_CC)
  350. #  if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
  351.   genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
  352. #else
  353.   throw *e;
  354. #endif
  355. #else
  356.   if (e)
  357.     cerr << e->message << endl;
  358.   exit(0);
  359. #endif
  360. }
  361.  
  362. #define THROWS(s)
  363.  
  364. #endif /* NCURSES_ETIP_H_incl */
  365.